﻿<?xml version="1.0" encoding="utf-8" ?>
<!--namespace必须用否者就报错（读取配置文件报：未将对象引用设置到对象的实例）-->
<sqlMap namespace="" xmlns="http://ibatis.apache.org/mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <statements >

    <!--上传附件开始 何航-->
    <select id="SearchAttachment" resultClass="HashTable">
      SELECT [Attach_ID]
      ,[Attach_FileName]
      ,[Attach_Path]
      ,[Attach_ObjectID]
      ,[Attach_ObjectModule]
      ,[Attach_ContentType]
      ,[Attach_Size]
      ,[Attach_IsTemp]
      ,[Attach_CreateTime]
      ,[Attach_CreateUserName]
      FROM [Attachment]
      <dynamic prepend="where">
        <isParameterPresent>
          <isNotEmpty prepend="and" property="Attach_ObjectModule">
            [Attach_ObjectModule] like '%$Attach_ObjectModule$%'
          </isNotEmpty>
          <isNotEmpty prepend="and" property="Attach_ObjectID">
            [Attach_ObjectID] like '%$Attach_ObjectID$%'
          </isNotEmpty>
        </isParameterPresent>
      </dynamic>
    </select>


    <insert id="InsertAttachment" parameterClass="hashtable" resultClass="int">
      INSERT INTO [Attachment]
      ([Attach_FileName]
      ,[Attach_Path]
      ,[Attach_ObjectID]
      ,[Attach_ObjectModule]
      ,[Attach_ContentType]
      ,[Attach_Size]
      ,[Attach_IsTemp]
      ,[Attach_CreateTime]
      ,[Attach_CreateUserName])
      VALUES
      (#Attach_FileName#,
      #Attach_Path#,
      #Attach_ObjectID#,
      #Attach_ObjectModule#,
      #Attach_ContentType#,
      #Attach_Size#,
      #Attach_IsTemp#,
      #Attach_CreateTime#,
      #Attach_CreateUserName#)
      <selectKey resultClass="int" Property="Attach_ID" type="post">
        SELECT @@IDENTITY AS value
      </selectKey>
    </insert>
    <delete id="DeleteAttachment" parameterClass="string" resultClass="int">
      DELETE FROM [Attachment]
      WHERE [Attach_ID]  in
      <iterate   open="(" close=")"  conjunction=",">
        #[]#
      </iterate>
    </delete>

    <select id="GetAttachment" parameterClass="string" resultClass="Kaiser.Modules.Hiner.Models.Product.Attachment">
      SELECT [Attach_ID]
      ,[Attach_FileName]
      ,[Attach_Path]
      ,[Attach_ObjectID]
      ,[Attach_ObjectModule]
      ,[Attach_ContentType]
      ,[Attach_Size]
      ,[Attach_IsTemp]
      ,[Attach_CreateTime]
      ,[Attach_CreateUserName]
      FROM [Attachment]
      WHERE [Attach_ID] =#Attach_ID#
    </select>

    <!--上传附件结束  何航-->
  </statements>
</sqlMap>